//全部
import React, {Component} from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';

import {meoneStyle as styles} from '../../../../styles';

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;
import Mestate from './mestate';
import sal from '../../../util/sal';
import Time from '../../../util/Time';
import {common_url} from "../../../util/fetch";


export default class Melist extends Component {

    constructor(props) {            //构造器只执行一次
        super(props);
        this.state = {a: true}
    };

    render() {
        return (
            <View style={styles.me_ouy}>
                <View style={styles.meoneallin}>
                    <Image source={
                        this.props.postionSend.company.companyPicture ?
                            {uri: common_url + "uploadImg/" + this.props.postionSend.company.companyPicture}
                            : require('../../../img/app/company.png')} style={styles.head}/>
                    <TouchableOpacity style={[styles.meoneline, {width: width * 0.7}]} activeOpacity={1}
                                      onPress={() => {
                                          this.choose()
                                      }}>
                        <View style={styles.meone1}>
                            <Text style={styles.meonepoz}>{this.props.postionSend.postion.postionName}</Text>
                            <Text
                                style={styles.meonemoney}>{sal(this.props.postionSend.postion.postionMm, this.props.postionSend.postion.postionYm)}</Text>
                        </View>
                        <View style={styles.meone2}>
                            <Text style={styles.meonename}>{this.props.postionSend.company.companyName}</Text>
                        </View>
                        <View style={styles.meone3}>
                            <Text style={styles.meonenon}>{this.props.postionSend.postion.postionSpace}</Text>
                            <Text style={styles.meonenon}>{this.props.postionSend.postion.postionExp}年经验</Text>
                            <Text style={styles.meonenon}>{this.props.postionSend.postion.postionEducation}</Text>
                        </View>
                        <View style={styles.meone4}>
                            {this.fieldName(this.props.postionSend.company.domains, 3)}
                        </View>
                    </TouchableOpacity>

                    <TouchableOpacity
                        style={styles.meonetrends}
                        activeOpacity={1}
                        onPress={() => {
                            this.goGet('Postionin', this.props.postionSend.postionId)
                        }}
                    >
                        <Text style={styles.meonetrendsin}>详情</Text>
                    </TouchableOpacity>

                    <Text style={styles.meonetime}>{Time(this.props.postionSend.sendTime1)}</Text >
                </View>
                <View>
                    {this.state.a ?
                        <View></View> :
                        <Mestate postionSend={this.props.postionSend}/>
                    }
                </View>
            </View>
        )
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, {useId: id});
    }

    choose() {
        this.setState({
            a: !this.state.a
        })
    }

    //经营领域
    fieldName(List, sl) {
        var data = {
            cont: List
        }
        var arr = [];
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr.push(
                <Text key={i} style={styles.meonesmall}>{data.cont[i].field.fieldName}</Text>
            )
        }
        return arr;
    }
}



